package com.x.uikit.page;

import android.content.Context;
import android.view.KeyEvent;
import android.view.View;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;

public class XPageLayer extends FrameLayout {
    public XPageLayer(@NonNull Context context) {
        super(context);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        return super.dispatchKeyEvent(event);
    }

    public boolean onBackPressed() {
        int count = getChildCount();
        boolean handle = false;
        if (count > 0) {
            for (int i = 0; i < count; i++) {
                View view = getChildAt(i);
                if (view instanceof XPageLayer) {
                    handle = ((XPageLayer) view).onBackPressed();
                    if (handle) {
                        break;
                    }
                }
            }
        }
        return handle;
    }
}
